﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using Microsoft.Xna.Framework.Content.Pipeline.Processors;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using BlackStar;

namespace BlackStarPipes
{
    [ContentTypeWriter]
    public class CursorContentWriter : ContentTypeWriter<Cursor>
    {
        protected override void Write(ContentWriter output, Cursor value)
        {

            output.Write(value.AssetName);
            output.WriteObject<Point>(value.Offset);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(CursorContentReader).AssemblyQualifiedName;
        }
    }

    [ContentTypeWriter]
    public class CursorListContentWriter : ContentTypeWriter<CursorList>
    {
        protected override void Write(ContentWriter output, CursorList value)
        {
            WriteCursorList(output, value);
        }

        public override string GetRuntimeReader(TargetPlatform targetPlatform)
        {
            return typeof(CursorListContentReader).AssemblyQualifiedName;
        }

        internal static void WriteCursorList(ContentWriter output, CursorList value)
        {
            output.Write(value.Count);
            foreach (KeyValuePair<string, Cursor> item in value)
            {
                output.Write(item.Key);
                output.WriteObject<Cursor>(item.Value);
            }
        }
    }

}
